#include<bits/stdc++.h>
using namespace std;
queue<int>s;
int main(){
	freopen("translate.in" , "r" , stdin);
	freopen("translate.out" , "w" , stdout);
	int m , n , ans = 0;
	int f[1010] = {0};
	cin >> m >> n;
	for(int i = 1 ; i <= n ; i++){
		int a;
		cin >> a;
		if(f[a] == 0){
			if(s.size() == m){
				auto it = s.front();
				f[it] -= 1;
				s.pop();
				s.push(a);
				ans++;
			}
			else{
				s.push(a);
				ans++;
			}
			f[a] += 1;
		}
	}
	cout << ans << endl;
	return 0;
}
